package day006.api_random;

import java.util.Random;
import java.util.Scanner;

public class RandomTest {
    public static void main(String[] args) {
        Random rand = new Random();
        int guess = rand.nextInt(100) + 1;
        System.out.println("1-100之间的随机数是：");
        while (true) {
            Scanner sc = new Scanner(System.in);
            int res = sc.nextInt();
            if (res == guess) {
                System.out.println("恭喜你猜对了！");
                break;
            } else if (res < guess) {
                System.out.println("数字猜小了，请再试一次！");
            } else {
                System.out.println("数字猜大了，请再试一次！");
            }
        }
    }
}
